WorkerScript.onMessage = function(message) {
    doLoadUser(message);
}


function doLoadUser(message) {
    var xhr = new XMLHttpRequest;
    var url = "https://production-2.sogeoapi.com/api/users/" + message.userId + "/profile?oauth_token=" + message.token;
    xhr.open("GET", url);
    xhr.onreadystatechange = function() {
        try {
            if (xhr.readyState == XMLHttpRequest.DONE) {
                var response = JSON.parse(xhr.responseText);
                console.log(xhr.responseText);
            }
        } catch(err) {
            WorkerScript.sendMessage({ 'result': 'FAILURE', 'message': err });
        }
    }
    xhr.send();
}
